import 'dart:ui';

import 'package:fish_redux/fish_redux.dart';
import 'package:flutter/cupertino.dart' hide Action;
import 'package:flutter/material.dart';
import 'package:multi_image_picker/multi_image_picker.dart';

import '../global_store/state.dart';

class PracticeEditState
    implements GlobalBaseState, Cloneable<PracticeEditState> {
  TextEditingController titleEditController;
  FocusNode focusNodeTitle;
  TextEditingController contentEditController;
  FocusNode focusNodeContent;
  List<Asset> photos;
  int currentOcrIndex = -1;
  bool isHomework = false;
  String id = '';
  bool isLoading = false;
  String typeValue;
  String gradeValue;
  Map<String, dynamic> result = {};

  @override
  PracticeEditState clone() {
    return PracticeEditState()
      ..themeColor = themeColor
      ..userInfo = userInfo
      ..titleEditController = titleEditController
      ..focusNodeTitle = focusNodeTitle
      ..contentEditController = contentEditController
      ..focusNodeContent = focusNodeContent
      ..currentOcrIndex = currentOcrIndex
      ..isHomework = isHomework
      ..id = id
      ..isLoading = isLoading
      ..result = result
      ..typeValue = typeValue
      ..gradeValue = gradeValue
      ..photos = photos;
  }

  @override
  Color themeColor;

  @override
  Map<String, dynamic> userInfo;
}

PracticeEditState initState(Map<String, dynamic> args) {
  if (args == null) {
    args = {};
  }

  final PracticeEditState state = PracticeEditState()
    ..titleEditController = TextEditingController()
    ..focusNodeTitle = FocusNode()
    ..contentEditController = TextEditingController()
    ..focusNodeContent = FocusNode()
    ..isHomework = args['isHomework'] ?? false
    ..id = args['id'] ?? ''
    ..typeValue = args['type'] ?? 'type1'
    ..gradeValue = args['grade'] ?? 'grade3'
    ..photos = args['list'] ?? [];

  return state;
}
